<template>
	<view>
		<view class="dizhi_1" v-if='JSON.stringify(address)=="{}"'>
			<button type="primary" size="40" @click="dizhi">请选择收货地址</button>
		</view>
		<view class="dizhi_q" v-else>
			<view class="row1">
				<view class="row1-left">
					<view class="username">
						收件人：<text>{{address.userName}}</text>
					</view>
				</view>
				<view class="row-right">
					<view class="phone">
						电话：<text>{{address.telNumber}}</text>
					</view>
					<uni-icons type="right" size="20"></uni-icons>
				</view>
			</view>
			<view class="row2">
				<view class='row2-shouhuo'>
					收货地址：<text>{{addresssStr}}</text>
				</view>
			</view>
		</view>
		<image src="../../static/cart_border@2x.png" mode="" class="dizhi-img"></image>
	</view>
</template>

<script>
	import {mapMutations,mapState} from 'vuex'
	export default {
		name: "dizhi",
		data() {
			return {
				// address: {}
			};
		},
		created() {
			console.log(this.$store)
		},
		computed: {
			...mapState('user_m',['address']),
			addresssStr() {
				return this.address.provinceName + this.address.cityName + this.address.countyName + this.address
					.detailInfo
			}
		},
		methods: {
			...mapMutations('user_m',['updateAddress']),
			async dizhi() {
				const [err, succ] = await uni.chooseAddress().catch(err => err);
				console.log(succ);
				if (err === null && succ.errMsg == 'chooseAddress:ok') {
					// this.address = succ;
					this.updateAddress(succ)
				} else {
					return uni.$showMsg()
				}

			}
		},
	}
</script>

<style lang="scss">
	.dizhi_1 {
		height: 100px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.dizhi_q {
		.row1 {
			height: 40px;
			display: flex;
			justify-content: space-between;

			.row1-right {
				.phone {
					display: flex;
					flex-wrap: nowrap;
				}

			}
		}
	}

	.dizhi-img {
		display: block;
		width: 100%;
		height: 5px;
	}
</style>
